package com.docmanage.web.controller.am;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.docmanage.am.service.impl.AmApprovalService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docmanage.common.annotation.Log;
import com.docmanage.common.core.controller.BaseController;
import com.docmanage.common.core.domain.AjaxResult;
import com.docmanage.common.enums.BusinessType;
import com.docmanage.am.domain.AmApproval;
import com.docmanage.common.utils.poi.ExcelUtil;
import com.docmanage.common.core.page.TableDataInfo;

/**
 * 审批Controller
 * @author yhd
 * @create 2023/12/4 11:28
 */
@RestController
@RequestMapping("/am/approval")
public class AmApprovalController extends BaseController
{
    @Resource
    private AmApprovalService amApprovalService;





    /**
     * 获取审批详细信息
     */
    @PreAuthorize("@ss.hasPermi('am:approval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(amApprovalService.selectAmApprovalById(id));
    }



    /**
     * 修改审批
     */
    @PreAuthorize("@ss.hasPermi('am:approval:edit')")
    @Log(title = "审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AmApproval amApproval)
    {
        return toAjax(amApprovalService.updateAmApproval(amApproval));
    }

    /**
     * 删除审批
     */
    @PreAuthorize("@ss.hasPermi('am:approval:remove')")
    @Log(title = "审批", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(amApprovalService.deleteAmApprovalByIds(ids));
    }
}